<template>
  <div class="main_box" style="padding:10px;">
    <div class="detail_wrap">
      <div class="tit">
        <h2>基础信息</h2>
        <el-button type="success" size="small" plain icon="fa fa-mail-forward" @click="returnList" > 返 回</el-button>
      </div>
      <div class="con">
        <ul>
          <li>
            <label class="label">标本箱编号:</label>
            <span>{{dataInfo.boxCode}}</span>
          </li>
          <li>
            <label class="label">标本箱名称:</label>
            <span>{{dataInfo.boxName}}</span>
          </li>
        </ul>
      </div>

      <div class="tit">
        <h2>温控设备信息</h2>
      </div>
      <div class="con">
        <ul>
          <li>
            <label class="label">设备编号:</label>
            <span>{{dataInfo.equipCode}}</span>
          </li>
          <li>
            <label class="label">设备名称:</label>
            <span>{{dataInfo.equipName}}</span>
          </li>
          <li>
            <label class="label">设备温度:</label>
            <span>{{dataInfo.equipTemperature}}</span>
          </li>
          <li>
            <label class="label">设备湿度:</label>
            <span>{{dataInfo.equipHumidity}}</span>
          </li>
          <li>
            <label class="label">设备位置:</label>
            <span>{{dataInfo.equipAddr}}</span>
          </li>
          <li>
            <label class="label">剩余电量:</label>
            <span>{{dataInfo.equipPower}}</span>
          </li>
          <li>
            <label class="label">设备状态:</label>
            <span>{{dataInfo.equipStatus}}</span>
          </li>
          <li>
            <label class="label">设备类型:</label>
            <span>{{dataInfo.equipType}}</span>
          </li>
          <li>
            <label class="label">设备最新上报时间:</label>
            <span>{{dataInfo.latestTime}}</span>
          </li>
        </ul>
      </div>

    </div>
  </div>
</template>

<script>

  import DisinfectApi from "@/api/disinfect/disinfect";
  import EquipApi from "@/api/equip/equip";

  export default {
  data() {
    return {
      dataInfo: "",
      fromType: 1
    };
  },
  methods: {
    getData(type) {
      if (type == 1){
        this.fromType = 1;
        DisinfectApi.getDisinfectInfo({
          esId: this.$route.query.id
        }).then(res => {
          this.dataInfo = res.data;
        });
      }else{
        this.fromType = 2;
        this.getDataUsage();
      }
    },
    getDataUsage() {
      EquipApi.getSpecimenUsage({
        syUserId: this.$route.query.id
      }).then(res => {
        this.dataInfo = res.data;
      });
    },
    formatDate(value) {
      return this.$Utils.formatDate(value, "yyyy-MM-dd");
    },
    returnList() {
      if(this.fromType == 1){
        this.$store.dispatch('delView', this.$route);
        this.$router.push({ path: "/equip/specimenManagement" });
      }else if(this.fromType == 2){
        this.$store.dispatch('delView', this.$route);
        this.$router.push({ path: "/report/reportManagement" });
      }
    }
  },
  beforeRouteEnter(to,from,next){
    next(vm => {
      if (from.path == '/equip/specimenManagement') {
        vm.getData(1);
      }else if (from.path == '/report/reportManagement') {
        vm.getData(2);
      }
    })
  }
};
</script>
<style lang="scss" src="@/assets/css/views/Detail.scss" scope>
</style>
